import { payLaunch } from '@/api/order'
import Storage from "./Storage";

export async function WxPayLaunch(payNo) {
  // uni.showLoading({
  //   title: "调用支付中",
  //   mask: true,
  // });
  let res = await payLaunch({ payNo, openId: Storage.get('openId') })
  if (res) {
    let {
      payObject: { timeStamp, nonceStr, packages, signType, paySign },

    } = res;
    return new Promise((resolve, reject) => {
      uni.hideLoading();
      uni.requestPayment({
        timeStamp,
        nonceStr,
        package: packages,
        signType,
        paySign,
        success: (res) => {
          resolve({
            success: true
          })

        },
        fail: (res) => {
          resolve({
            success: false
          })

        },
        complete: function (res) { },
      });
    })


  }

}